<?php
class Store extends CI_Model {

    function __construct()
    {
        parent::__construct();
    }
	
	function get_all($limit=10000, $offset=0)
	{
		$this->db->from('stores');
		$this->db->where('active', 1);
		$this->db->order_by("store_id", "asc");
		$this->db->limit($limit);
		$this->db->offset($offset);
		return $this->db->get();		
	}
	
	function get_info($store_id)
	{
		$this->db->from('stores');	
		$this->db->where('store_id',$store_id);
		$query = $this->db->get();
		
		if($query->num_rows()==1)
		{
			return $query->row();
		}
		else
		{
			//Get empty base parent object
			$store_obj=parent::get_info(-1);
			
			//Get all the fields from stores table
			$fields = $this->db->list_fields('stores');
			
			//append those fields to base parent object, we we have a complete empty object
			foreach ($fields as $field)
			{
				$store_obj->$field='';
			}
			
			return $store_obj;
		}
	}
}
?>